#include "DXConsole.h"
#include "GlobalDefines.h"

DXConsole::DXConsole()
{
	DXInitFont();

}

DXConsole* DXConsole::Instance()
{
  static DXConsole instance;

  return &instance;
}
void DXConsole::DXInitFont()
{
	m_font=NULL;

	D3DXCreateFont( dxMgr.getDevice(),     //D3D Device
                     38,               //Font height
                     0,                //Font width
                     FW_NORMAL,        //Font Weight
                     1,                //MipLevels
                     false,            //Italic
                     DEFAULT_CHARSET,  //CharSet
                     OUT_DEFAULT_PRECIS, //OutputPrecision
                     DEFAULT_QUALITY, //Quality
                     DEFAULT_PITCH|FF_DONTCARE,//PitchAndFamily
                     "Times New Roman",          //pFacename,
                     &m_font);         //ppFont
}

void DXConsole::DXOut( LPCSTR a_out,unsigned int a_left,unsigned int a_top,unsigned int a_right,unsigned int a_bottom)
{
	m_text.left=a_left;
	m_text.top=a_top;
	m_text.right=a_right;
	m_text.bottom=a_bottom;
	m_text.OutputString=a_out;
}

void DXConsole::DXDrawText(D3DCOLOR fontColor)
{
	RECT font_rect;
	SetRect(&font_rect,m_text.top,m_text.left,m_text.right,m_text.bottom);

	m_font->DrawText(NULL,        //pSprite
					m_text.OutputString,  //pString
                    -1,          //Count
                    &font_rect,  //pRect
                    DT_LEFT|DT_NOCLIP,//Format,
                    fontColor); //Color
}